package ke07.rmi;

import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;

public class RMIClient {
	
	public static void main(String[] args) throws RemoteException, NotBoundException, MalformedURLException {
	    //only localhost
		Registry registry = LocateRegistry.getRegistry();
	    RMIRemoteInterface multiplyer = (RMIRemoteInterface) registry.lookup( "Multiplyer" );
		
		//with ip-adress and registry name
	    RMIRemoteInterface multiplyer2 = (RMIRemoteInterface) Naming.lookup("//127.0.0.1/Multiplyer");
	    
	    System.out.println("3 * 22 = "+ multiplyer.multiply( 22, 3 ) );
	    System.out.println("3 * 22 = "+ multiplyer2.multiply( 22, 3 ) );
	}
}
